package community.hospital.service.application.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import community.hospital.convert.MenuConvert;
import community.hospital.entity.Menu;
import community.hospital.entity.request.ListMenuRequest;
import community.hospital.entity.request.MenuRequest;
import community.hospital.service.application.MenuApplicationService;
import community.hospital.service.domain.MenuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author：ydj
 * @Date：2023/1/26 20:53
 */
@Service
public class MenuApplicationServiceImpl implements MenuApplicationService {
    @Resource
    private MenuService menuService;
    @Override
    public List<Menu> listMenuByRoleId(Long roleId) {
        return menuService.listMenuByRoleId(roleId);
    }

    @Override
    public Boolean addMenu(MenuRequest request) {
        Menu menu = MenuConvert.INSTANCE.convertToMenu(request);
        return menuService.save(menu);
    }

    @Override
    public Boolean removeMenus(List<Long> ids) {
        return menuService.removeByIds(ids);
    }

    @Override
    public Boolean updateMenu(MenuRequest request) {
        Menu menu = MenuConvert.INSTANCE.convertToMenu(request);
        return menuService.updateById(menu);
    }

    @Override
    public Page<Menu> listMenu(ListMenuRequest request) {
        return menuService.listMenu(request);
    }


}
